package ${package.Controller}${cfg.moduleName};

import ${cfg.basePath}.entity.${cfg.moduleName}${entity};
import com.example.suuu.tools.log.LogPrint;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import ${cfg.basePath}.service.${cfg.moduleName}impl.${entity}ServiceImpl;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.CrossOrigin;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import com.example.suuu.model.result.ResultVo;
import com.example.suuu.project.system.query.${entity}Query;

import javax.annotation.Resource;

/**
 * @desc ${table.comment!} API接口
 * @author sun
 * @date ${date}
 */
@CrossOrigin
@RestController
@RequestMapping("/${table.entityPath}")
@Api(value = "/${table.entityPath}", tags = {"${table.comment!} API接口"})
@ApiSupport(author = "sun")
public class ${entity}Controller{

    @Resource
    public ${entity}ServiceImpl ${table.entityPath}Service;


    @PostMapping("/add")
    @LogPrint("${table.comment!}新增")
    @ApiOperation(value = "${table.comment!}新增",notes = "${table.comment!}新增")
    @ApiOperationSupport(ignoreParameters = {"id"})
    public ResultVo add(@Validated @RequestBody ${entity} u) {
        return ResultVo.ResultVoSuccess(${table.entityPath}Service.add(u));
    }
    @PutMapping("/update")
    @LogPrint("${table.comment!}修改")
    @ApiOperation(value = "${table.comment!}修改",notes = "${table.comment!}修改")
    @ApiOperationSupport(ignoreParameters = {})
    public ResultVo update(@Validated @RequestBody ${entity} u) {
        return ResultVo.ResultVoSuccess(${table.entityPath}Service.update(u));
    }
    @DeleteMapping("/del/{id}")
    @LogPrint("${table.comment!}删除")
    @ApiOperation(value = "${table.comment!}删除",notes = "${table.comment!}删除")
    public ResultVo del(@Validated @PathVariable(value="id") Integer id) {
        return ResultVo.ResultVoSuccess(${table.entityPath}Service.del(id));
    }
    @GetMapping("/getlist")
    @LogPrint("${table.comment!}查询")
    @ApiOperation(value = "${table.comment!}查询",notes = "${table.comment!}查询")
    @ApiOperationSupport(ignoreParameters = {})
    public ResultVo get(${entity}Query query) {
        return ResultVo.ResultVoSuccess(${table.entityPath}Service.pagVo(query));
    }
    @GetMapping("/getById/{id}")
    @LogPrint("${table.comment!}id查询")
    @ApiOperation(value = "${table.comment!}id查询",notes = "${table.comment!}id查询")
    @ApiOperationSupport(ignoreParameters = {})
    public ResultVo getById(@Validated @PathVariable(value="id") Integer id) {
        return ResultVo.ResultVoSuccess(${table.entityPath}Service.getById(id));
    }
}